#include <iostream>
#include <set>

using std::cout;
using std::endl;
using std::set;

template <typename Container>
void display(const Container &con)
{
    for(auto &elem : con)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

void test0()
{
    set<int> number = {1, 3, 7, 9, 5, 8, 10, 11, 13, 15};
    display(number);

    for(auto it = number.begin(); it != number.end(); ++it)
    {
        /* if(*it & 1) */
        if(1 == *it % 2)
        {
            /* number.erase(it);//error */
            it = number.erase(it);
            /* number.erase(it++); */
        }
    }

    cout << endl << "删除连续的奇数之后的结果" << endl;
    display(number);
}

void test()
{
    set<int> number = {1, 3, 7, 9, 5, 8, 10, 11, 13, 15};
    display(number);

    for(auto it = number.begin(); it != number.end(); )
    {
        /* if(*it & 1) */
        if(1 == *it % 2)
        {
            /* it = number.erase(it); */
            number.erase(it++);
        }
        else
        {
            ++it;
        }
    }

    cout << endl << "删除连续的奇数之后的结果" << endl;
    display(number);
}
int main(int argc, char *argv[])
{
    test();
    return 0;
}

